package com.heima.comment.controller;

import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.CommentDTO;
import com.heima.model.comment.dtos.CommentLikeDTO;
import com.heima.model.comment.dtos.CommentSaveDTO;
import com.heima.model.comment.pojos.ApComment;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    CommentService commentService;
    @PostMapping("/save")
    private ResponseResult saveComment(@RequestBody @Validated CommentSaveDTO dto) throws Exception {
        return commentService.saveComment(dto);
    }
    @PostMapping("/like")
    private ResponseResult like(@RequestBody @Validated CommentLikeDTO dto){
        return commentService.like(dto);
    }
    @PostMapping("/load")
    private ResponseResult<ApComment> findByArticleId(@RequestBody @Validated CommentDTO dto){
        return commentService.findByArticleId(dto);
    }

}
